package JUC;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class CompletableFutureAPIDemo3 {
    public static void main(String[] args) throws ExecutionException, InterruptedException, TimeoutException {
       CompletableFuture.supplyAsync(() -> {
//            try {TimeUnit.SECONDS.sleep(3);} catch (InterruptedException e) {throw new RuntimeException(e);}
            return 1;
        }).thenApply(f->f+1).thenApply(f->f+1).thenApply(f->f+1).
                thenAccept(System.out::println);

    }
}
